<template>
  <div id="app2">
    <el-container>
      <el-aside width="200px" id="said">
        <el-row class="tac">
          <el-col :span="12" id="left">
            <el-menu default-active="2" class="el-menu-vertical-demo">
              <el-menu-item index="3">
                <span slot="title">欢迎光临:&nbsp;{{ username }}</span>
              </el-menu-item>
              <el-menu-item index="1">
                <i class="el-icon-menu"></i>
                <span slot="title">首页</span>
              </el-menu-item>
              <el-submenu index="2">
                <template slot="title">
                  <div>
                    <i class="el-icon-document"></i>
                    <span class="span">页面管理</span>
                  </div>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="1-1" id="el" @click="myshop1"
                    >我的商铺</el-menu-item
                  >
                  <el-menu-item index="1-2" id="el" @click="myshop2"
                    >添加商铺</el-menu-item
                  >
                  <el-menu-item index="1-3" id="el" @click="myshop3"
                    >商铺管理</el-menu-item
                  >
                  <el-menu-item index="1-4" id="el" @click="myshop4"
                    >食品管理</el-menu-item
                  >
                  <el-menu-item index="1-5" id="el" @click="myshop5"
                    >订单管理</el-menu-item
                  >
                </el-menu-item-group>
              </el-submenu>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-main id="main">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item><a href="#">业务管理</a></el-breadcrumb-item>
          <el-breadcrumb-item>商铺管理</el-breadcrumb-item>
          <el-dropdown>
            <span class="el-dropdown-link">
              个人中心<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <v-nav></v-nav>
            </el-dropdown-menu>
          </el-dropdown>
        </el-breadcrumb>
        <div id="div">
          <el-input v-model="input" placeholder="店铺名称" id="inp"></el-input>
          <el-button type="primary">搜索</el-button>
        </div>
        <template>
          <el-table :data="tableData" style="width: 100%;color:black" id="tr">
            <el-table-column label="商家名称" width="180">
              <template slot-scope="scope">
                <div>
                  <span style="margin-left: 10px" id="span">{{
                    scope.row.shopname
                  }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="商家地址" width="180">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.addr }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="商家电话" width="180">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.tel }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="商家图片" width="180">
              <template slot-scope="scope">
                <div>
                  <img :src="scope.row.shoppic" alt="" />
                </div>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import nav from "../../components/nav.vue";
import { mapstate, mapActions } from "vuex";
import allshopModel from "../../model/allshopModel";
export default {
  components: {
    "v-nav": nav
  },
  data() {
    return {
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false,
      shopname: "",
      currentPage2: 1,
      scope: {},
      input: "",
      options: [
        { value: "", label: "全部" },
        {
          value: 1,
          label: "审核中"
        },
        {
          value: 2,
          label: "审核通过"
        },
        {
          value: 3,
          label: "审核拒绝"
        }
      ],
      tableData: [],
      value: ""
    };
  },
  async created() {
    console.log(11);
    let info = window.localStorage.getItem("info");
    console.log(info);
    this.username = info;
    let result = await allshopModel.query();
    this.list = result;
    console.log(this.list);
    console.log(result);
    this.tableData = result.data.data;
    console.log(this.tableData);
  },
  methods: {
    search() {
      //alert(this.value);
    },
    async changeType(_id, type) {
      this.updateById({
        _id,
        type,
        cb: () => {
          alert("更新失败");
        }
      });
    },

    myshop1() {
      this.$router.push("/shops/myshop");
    },
    myshop2() {
      this.$router.push("/shops/add");
    },
    myshop3() {
      this.$router.push("/shops/shop");
    },
    myshop4() {
      this.$router.push("/shops/food");
    },
    myshop5() {
      this.$router.push("/shops/order");
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  }
};
</script>

<style scoped>
#said {
  height: 2000px;
  background-color: #fff;
}
img {
  width: 50px;
  height: 50px;
}
.block {
  margin-top: 30px;
}
.el-pager {
  color: red;
}
li {
  color: red;
}
.block {
  color: black;
}
#btn {
  background-color: #00f;
}
#span {
  color: black;
  display: inline-block;
  width: 200px;
}
.el-input__inner {
  width: 100px;
}
#div {
  display: flex;
  justify-content: space-between;
}
#el {
  color: #fff;
}
.span {
  background-color: rgb(10, 6, 51);
}
.el-menu-item.is-active {
  background-color: rgb(10, 6, 51);
  color: blue;
}
.div {
  margin-bottom: 20px;
}
.el-breadcrumb {
  border-bottom: 1px solid gray;
  margin-bottom: 20px;
}
.el-main {
  padding: 0;
  margin-left: 20px;
}
.el-aside {
  overflow: hidden;
}
</style>
